﻿using Microsoft.AspNetCore.Authorization;
using System;
using System.Linq;

namespace Fast.Authorization
{
    /// <summary>
    /// 授权特性
    /// </summary>
    [SkipScan, AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Method)]
    public sealed class FastAuthorizeAttribute : AuthorizeAttribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="policies">多个策略</param>
        public FastAuthorizeAttribute(params string[] policies)
        {
            if (policies != null && policies.Length > 0) Policy = $"{string.Join(',', policies.Select(p => PolicyConst.AuthorizePrefix + p))}";
        }
    }
}
